<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<table cellpadding="0" cellspacing="0" width="730" align="center" border="0">
		<tr>
			<td align="left" colspan="3">
			View by:&nbsp;
			<select name="txtcat">
				<option value="0">All Categories</option>
				<c:forEach var="y" begin="0" end="${fn:length(categories)-1 }" step="1" varStatus="status">
					<option value="${categories[y].CATEGORY_ID}">
						<c:out value="${categories[y].CATEGORY_NAME}"></c:out>
					</option>
				</c:forEach>
			</select>
			</td>
			<td colspan="4" align="right"><a href="upload_page.html"><u>Upload a new file</u></a></td>
		</tr>
		<tr><td colspan="6" height="8"> </td></tr>
	<tr class="table_title" align="center" >
		<td width="6%">ID</td>	
		<td width="30%">Subject</td>	
		<td width="35%">Short Description</td>	
		<td width="10%">Date</td>
		<td width="10%">Share to</td>
		<td width="10%">Remove</td>
	</tr>
	<%
		String bgcolor="#EEE";
	%>
	<c:forEach var="x" begin="0" end="${fn:length(data)-1}" step="1" varStatus ="status">
		<%
			bgcolor=(bgcolor=="#EEE")?"#FFF":"#EEE";
		%>
		<c:if test="${x>=StartingRow && x<=EndingRow}">
			<tr bgcolor="<%=bgcolor%>">
				<td height="40" style="border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;"><a href="edit_myupload.html?id=${data[x].FILE_ID}"><c:out value="${data[x].FILE_ID}"/></a></td>
				<td align="center" style="border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;">&nbsp;<a href="edit_myupload.html?id=${data[x].FILE_ID}"><c:out value="${data[x].FILE_TITLE}"/></a></td>
				<td align="left" style="border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;padding-right: 4px; padding-left: 4px;">
					<c:choose>
						<c:when test="${fn:length(data[x].FILE_DESC)>=80}">
							<c:out value="${fn:substring(data[x].FILE_DESC,0,80)}"/>...
						</c:when>
						<c:otherwise>
							<c:out value="${data[x].FILE_DESC}"/>
						</c:otherwise>
					</c:choose>
				</td>
				<td style="border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;"><c:out value="${data[x].DATE_UPLOAD}"/></td>
				<td style="border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;"><a href=""><img src="images/sharefile.png" width="25" height="25"></a></td>
				<td style="border:solid 1px #DDD; border-top:solid 0px #DDD;"><img src="images/remove.png" width="18" height="18" onclick="deleteUpload(${data[x].FILE_ID})" style="cursor: pointer;"></td>
			</tr>
		</c:if>
	</c:forEach>
	<tr>
		<td height="30" valign="middle" colspan="8">
		<c:if test="${PageCount>1}">
			<c:if test="${page>1}">
				<a href="myuploads.html?page=${page-1}">Previous</a>
			</c:if>
			<c:if test="${page<=1}">
				<label style="color: #333">Previous</label>
			</c:if>
			
				<c:forEach var="i" begin="1" end="${PageCount}" step="1" varStatus ="status">
					<c:if test="${i==page}">
						<b style="color: #333"><c:out value="${i}" /></b>
					</c:if>
					<c:if test="${i!=page}">
						<a href="myuploads.html?page=${i}"><c:out value="${i}" /></a>
					</c:if>
				</c:forEach>
				
			<c:if test="${page<PageCount}">
				<a href="myuploads.html?page=${page+1}">Next</a>
			</c:if>
			<c:if test="${page>=PageCount}">
				<label style="color: #333">Next</label>
			</c:if>
		</c:if>
		</td>
	</tr>
</table>
</body>
</html>